﻿@model IEnumerable<BuySoftwareOnline.Domain.Product>

@{
    ViewBag.Title = "Index";
}

<h2>All Products</h2>
<table class="Grid">
    <tr>
        <th>ProductID</th>
        <th>ProductName</th>
        <th class="NumericCol">UnitPrice</th>
        <th>Actions</th>
    </tr>
    @foreach (var item in Model)
    {
    <tr>
        <td>@item.ProductID</td>
        <td>
        @if (item.ProductName.ToString().Length > 40)
        {
            @Html.ActionLink(item.ProductName.ToString().Substring(0, 40) + ".......", "Edit", new { item.ProductID })
        }
        else
        {
            @Html.ActionLink(item.ProductName, "Edit", new { item.ProductID })
        }
        </td>
        <td class="NumericCol">@item.UnitPrice.Value.ToString("c")</td>
        <td>
            @using (Html.BeginForm("Delete", "Admin"))
            {
                @Html.Hidden("ProductID", item.ProductID)
                <input type="submit" value="Delete" />
            }
        </td>
    </tr>
    }
</table>
<p>@Html.ActionLink("Add a new product", "Create")</p>
